
$(function(){
    var switchValue=function () {
        var hidden = "hidden_";
        $("input[id^=" + hidden + "]").each(function () {
            var fromElement = $(this).attr("id");
            var toElement = fromElement.substring(hidden.length, fromElement.length);

            var fromVal = $("#" + fromElement).val();

            var type= $("#" + fromElement).data("type");
            console.log("type---->",type);
            if(!!type){
                switch (type) {
                    case "date":
                    // <input class="form-control layer-date" placeholder="YYYY-MM-DD hh:mm:ss" id="subscribeTime"
                    //     name="subscribeTime"
                    //     onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                        var date = $.date.fmtDate(fromVal);
                        $("#" + toElement).val(date);
                        break;
                    default :
                        $("#" + toElement).val(fromVal);
                        break;
                }
            }else{
                $("#" + toElement).val(fromVal);
            }

        });
    }

//将隐藏域id为hidden_开头的值赋值到对于的文本域中
//data-type 为string，date
//<input data-type="date" th:value="*{subscribeTime}" id="hidden_subscribeTime" type="hidden">
    switchValue();
});

